#!/bin/bash

cd upload/build
cmake ..
make
cd ..
echo "上传："
# stop
kill -9 $(ps aux|grep "./build/upload" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10007 -f ./build/upload
if [ $? -eq 0 ];then
    echo "upload启动成功！"
else
    echo "upload启动失败！"
fi
echo ""


cd ../register/build
cmake ..
make
cd ..
echo "注册："
# stop
kill -9 $(ps aux|grep "./build/register" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10001 -f ./build/register
if [ $? -eq 0 ];then
    echo "register启动成功！"
else
    echo "register启动失败！"
fi
echo ""


cd ../login/build
cmake ..
make
cd ..
echo "登录："
# stop
kill -9 $(ps aux|grep "./build/login" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10000 -f ./build/login
if [ $? -eq 0 ];then
    echo "login启动成功！"
else
    echo "login启动失败！"
fi
echo ""

cd ../myfiles/build
cmake ..
make
cd ..
echo "我的文件："
kill -9 $(ps aux|grep "./build/myfiles" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10003 -f ./build/myfiles
if [ $? -eq 0 ];then
    echo "myfiles启动成功！"
else
    echo "myfiles启动失败！"
fi
echo ""

cd ../md5/build
cmake ..
make
cd ..
echo "MD5："
kill -9 $(ps aux|grep "./build/md5" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10002 -f ./build/md5
if [ $? -eq 0 ];then
    echo "md5启动成功！"
else
    echo "md5启动失败！"
fi
echo ""

cd ../dealfile/build
cmake ..
make
cd ..
echo "处理文件："
kill -9 $(ps aux|grep "./build/dealfile" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10004 -f ./build/dealfile
if [ $? -eq 0 ];then
    echo "dealfile启动成功！"
else
    echo "dealfile启动失败！"
fi
echo ""

cd ../sharefiles/build
cmake ..
make
cd ..
echo "分享文件："
kill -9 $(ps aux|grep "./build/sharefiles" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10005 -f ./build/sharefiles
if [ $? -eq 0 ];then
    echo "sharefiles启动成功！"
else
    echo "sharefiles启动失败！"
fi
echo ""

cd ../dealsharefile/build
cmake ..
make
cd ..
echo "处理文件："
kill -9 $(ps aux|grep "./build/dealsharefile" | grep -v grep | awk '{print $2}')
spawn-fcgi -a 127.0.0.1 -p 10006 -f ./build/dealsharefile
if [ $? -eq 0 ];then
    echo "dealsharefile启动成功！"
else
    echo "dealsharefile启动失败！"
fi
echo ""